package com.icms.core.dbutil;

import javax.sql.DataSource;

import org.apache.commons.dbutils.QueryRunner;
import org.springframework.stereotype.Component;

@Component
public class DBUtilsHelper implements IDBUtilsHelper {

	private DataSource ds ;
	
	private QueryRunner qr ;
	
	public DBUtilsHelper() {
		ds = DBConnectionPool.getInstance().getDataSource() ;
		if(null != this.ds) {
			//使用QueryRunner会自动关闭连接
			this.qr = new QueryRunner(ds) ;
		}
	}
	public DBUtilsHelper(DataSource ds) {
		this.ds = ds ;
		//使用QueryRunner会自动关闭连接
		this.qr = new QueryRunner(ds) ;
	}
	
	public DataSource getDataSource() {
		return this.ds ;
	}
	
	public QueryRunner getQr() {
		return this.qr ;
	}
}
